package servlets;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import domain.ContactGroup;
import domain.IDAOContact;

public class addContactLinkAction extends Action {

	public ActionForward execute(final ActionMapping pMapping, ActionForm pForm, final HttpServletRequest pRequest, final HttpServletResponse pResponse) {
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(pRequest.getSession().getServletContext());
		IDAOContact dao = (IDAOContact)context.getBean("daoContact");	
		List<ContactGroup> books = dao.getAllBook();
		pRequest.setAttribute("books", books);
		return pMapping.findForward("addContactLinkPage");
	}
}